{include file='public/meta' }
  <title>会员回收站列表 - 木鱼内容管理系统</title>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">会员查找</label>
            <div class="layui-input-block">
              <input type="text" name="keywords" id="keywords" placeholder="请输入关键词" autocomplete="off" class="layui-input">
            </div>
          </div>
          
          
          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-useradmin" type="submit" onclick="so()">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
          </div>
        </div>
      </div>
      
      <div class="layui-card-body">
        <div style="padding-bottom: 10px;">
          <button class="layui-btn layui-btn-danger layuiadmin-btn-useradmin" onclick="delAll()">批量删除</button>
          <button class="layui-btn layuiadmin-btn-useradmin" onclick="huanyuanAll()">批量还原</button>
        </div>

		
		<div class="layui-table-body layui-table-main">
			<table class="layui-table">
				<thead>
				<tr>
					<th class=" layui-table-col-special">
						<div class="layui-table-cell laytable-cell-checkbox">
							<input type="checkbox" id="checkAll" onclick="isCheck()">
						</div>
					</th>
					<th><div class="layui-table-cell" align="center"><span>ID</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>会员账户</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>昵称</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>性别</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>手机</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>邮箱</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>删除时间</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>状态</span></div></th>
					<th><div class="layui-table-cell" align="center"><span>操作</span></div></th>
				</tr>
				</thead>
				<tbody>
				{foreach $list as $v}
				<tr align="center">
					<td class="layui-table-col-special">
						<input type="checkbox" name="fav" value="{$v.id}">
					</td>
					<td>{$v.id}</td>
					<td>{$v.account}</td>
					<td>{$v.name}</td>
					<td>{$v.sex}</td>
					<td>{$v.phone}</td>
					<td>{$v.email}</td>
					<td>{:date('Y-m-d',$v.create_time)}</td>
					<td><div class="layui-table-cell">
						<button type="button" class="layui-btn-xs layui-btn layui-btn-danger">已删除</button>
						</div>
					</td>
					<td align="center" data-off="true" class="layui-table-col-special">
					<div class="layui-table-cell">
						
						<button type="button" class="layui-btn layui-btn-xs" onclick="huanyuan('{$v.id}')"><i class="layui-icon layui-icon-ok-circle"></i>还原</button>
						<button type="button" class="layui-btn layui-btn-xs layui-btn-danger del" data-name="{$v.name}" data-id="{$v.id}"><i class="layui-icon layui-icon-delete"></i>删除</button>
						</div>
					</td>
				</tr>
				{/foreach}
				</tbody>
			</table>
		</div>
		<div class="layui-box layui-laypage layui-laypage-molv">{$list|raw}</div>
      </div>
    </div>
  </div>

  {include file='public/footer' }
  <script>
  layui.config({
    base: '__ADMINST__layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'useradmin', 'table'], function(){
    var $ = layui.$
    ,form = layui.form
    ,table = layui.table;

	
    //删除操作
	$(".del").click(function(){
		//获取删除信息和对应id
		var name = $(this).attr('data-name');
		var id = $(this).attr('data-id');
		//alert(name);
		layer.msg('是否彻底删除?',{
			time:5000,
			shade:0.3,
			btn:['删除','取消'],
			yes:function() {
				//执行删除
				$.post("{:url('Member/reallyDel')}",{id:id},function(data){
					layer.msg(data.msg,{time:2000},function(){
						if(data.url) location.href = data.url;
					});
				});
			}
		});
	});
	
  });



	//全选功能
	function isCheck(){
		var IsCheck= document.getElementById("checkAll");
		if(IsCheck.checked == false){
			var groupC = document.getElementsByName("fav");
			for(var i=0;i<groupC.length;i++){
				groupC[i].checked=false;
			}
		}
		if(IsCheck.checked == true){
			var groupC = document.getElementsByName("fav");
			for(var i=0;i<groupC.length;i++){
				groupC[i].checked=true;
			}
		}
	}
	
	//会员回收站批量删除
	function delAll(){
		var id=$("tbody input:checkbox");
		var ids=[];
		for(i=0;i<id.length;i++){
			if($(id[i]).is(":checked")){
				ids+=$(id[i]).val()+',';
			}
		}
		var delid = ids;
		if(delid == ""){
			layer.msg("当前未选择任何信息！",{icon:2,time:2000});
		}else{
			layer.msg('确认彻底删除？',{
				time:5000,
				shade:0.3,
				btn:['确认','取消'],
				yes: function(){
					//执行删除
					$.post("{:url('Member/reallyDel')}",{id:delid},function(data){
						if(data.code === 1){
							layer.msg(data.msg,{time:2000},function(){
								if(data.url) location.href = data.url;
							});
						}else{
							layer.msg(data.msg,{time:2000});
						}
					})
				}
			});
		}
	}


	//会员回收站还原
	function huanyuan(id){
	    layer.msg("确认要还原吗？",{
	        time:5000,
	        shade:0.3,
	        btn:['确认','取消'],
	        yes:function(){
	            //执行还原
	            $.post("{:url('member/huanyuan')}",{id:id},function(data){
	                if(data.code === 1){
	                    layer.msg(data.msg,{time:2000},function(){
	                        if(data.url) location.href = data.url;
	                    });
	                }else{
	                    layer.msg(data.msg,{time:2000});
	                }
	            });
	        }
	    });
	}


	//会员回收站批量还原
	function huanyuanAll(){
		var id=$("tbody input:checkbox");
		var ids=[];
		for(i=0;i<id.length;i++){
			if($(id[i]).is(":checked")){
				ids+=$(id[i]).val()+',';
			}
		}
		var delid = ids;
		if(delid == ""){
			layer.msg("当前未选择任何信息！",{icon:2,time:2000});
		}else{
			layer.msg('确认还原？',{
				time:5000,
				shade:0.3,
				btn:['确认','取消'],
				yes: function(){
					//执行删除
					$.post("{:url('Member/huanyuan')}",{id:delid},function(data){
						if(data.code === 1){
							layer.msg(data.msg,{time:2000},function(){
								if(data.url) location.href = data.url;
							});
						}else{
							layer.msg(data.msg,{time:2000});
						}
					})
				}
			});
		}
	}	


	//点击搜索
	function so(){
		var keywords = $("#keywords").val();
		if(keywords == ""){
			layer.msg("请输入搜索内容！",{time:2000});
		}else{
			layer.open({
				title:"搜索内容",
				type:2,
				area:['100%','100%'],
				content: "{:url('Member/recycleSearch')}"+"?keywords="+keywords,
				end:function(){
					location.reload();
				}
			});
		}
		console.log(keywords);
	}
	

  </script>
</body>
</html>
